﻿using System;
using System.ComponentModel;

namespace ExFlash.Records
{
    [TypeConverter(typeof(CXFormAlphaRecordConverter))]
    public class CXFormAlphaRecord : CXFormRecord
    {
        
        public Int16 AlphaMultTerm
        {
            get;
            private set;
        }

        public Int16 AlphaAddTerm
        {
            get;
            private set;
        }

        #region ISwfSerializable Members

        public override void SwfDeserialize(BinaryBitReader reader)
        {
            HasAddTerms = reader.ReadBoolean();

            HasMultTerms = reader.ReadBoolean();

            Nbits = (Byte)reader.ReadUInt32(4);

            if (HasMultTerms)
            {
                RedMultTerm = (Int16)reader.ReadInt32(Nbits);
                GreenMultTerm = (Int16)reader.ReadInt32(Nbits);
                BlueMultTerm = (Int16)reader.ReadInt32(Nbits);
                AlphaMultTerm = (Int16)reader.ReadInt32(Nbits);
            }

            if (HasAddTerms)
            {
                RedAddTerm = (Int16)reader.ReadInt32(Nbits);
                GreenAddTerm = (Int16)reader.ReadInt32(Nbits);
                BlueAddTerm = (Int16)reader.ReadInt32(Nbits);
                AlphaAddTerm = (Int16)reader.ReadInt32(Nbits);
            }

            reader.AlignBits();
        }

        public override void SwfSerialize(byte[] arr, ref int offset)
        {
            throw new NotImplementedException();
        }

        #endregion
    }

    public class CXFormAlphaRecordConverter : ExpandableObjectConverter
    {

    }
}
